package com.mvc4g.example.client.product.views;

import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;
import com.mvc4g.client.Event;
import com.mvc4g.example.client.product.ProductBean;

public class DisplayProductView extends AbstractProductView {

	private Label name = null;
	private Label price = null;
	private ProductBean product = null;

	protected void finishCreation() {
		name = new Label();
		price = new Label();
		grid.setWidget(0, 1, name);
		grid.setWidget(1, 1, price);
	}

	public void init(ProductBean customer) {
		this.product = customer;
		name.setText(customer.getName());
		price.setText(customer.getPrice());
	}

	protected Widget getLastName() {
		if (name == null) {
			name = new Label();
		}
		return name;
	}

	protected Widget getFirstName() {
		if (price == null) {
			price = new Label();
		}
		return price;
	}

	protected String getButtonText() {
		return "Copy";
	}

	protected void buttonAction() {
		controller.handleEvent(new Event(COPY_PRODUCT, product));
	}

}
